package ro.ase.catalog.security.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import ro.ase.catalog.beans.SchoolClass;
import ro.ase.catalog.beans.Student;
import ro.ase.catalog.beans.Teacher;
import ro.ase.catalog.beans.User;
import ro.ase.catalog.beans.dto.AverageDTO;
import ro.ase.catalog.beans.dto.StudentDTO;
import ro.ase.catalog.beans.dto.TeacherDisciplineStudentsDTO;
import ro.ase.catalog.security.dao.IStudentDAO;
import ro.ase.catalog.security.service.IStudentService;

import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * User: Ioana
 * Date: 5/12/14
 * Time: 7:49 PM
 * To change this template use File | Settings | File Templates.
 */
public class StudentServiceImpl implements IStudentService {

    @Autowired
    private IStudentDAO studentDAO;

    public void addStudent(Student student) {
        studentDAO.save(student);
    }

    public Boolean saveTransactionalStudent(User user, Student student) {
       return studentDAO.saveTransactionalStudent(user,student);
    }

    public List<StudentDTO> findByName(String searchName, int start, int limit) {
        return studentDAO.findByName(searchName, start, limit);
    }

    public Student getStudentById(Integer id) {
        return studentDAO.get(id);
    }

    public void updateStudent(Student studentUpdate) {
        studentDAO.update(studentUpdate);
    }

    public List<TeacherDisciplineStudentsDTO> findAllStudentsByClass(Teacher teacher, SchoolClass schoolClass){
        return studentDAO.findAllStudentsByClass(teacher, schoolClass);
    }

    public List<AverageDTO> getAverageByClasses(SchoolClass classMaster) {
        return studentDAO.getAverageByClasses(classMaster);
    }

    public TeacherDisciplineStudentsDTO getAvgForStudentAtDiscipline(Teacher teacher, Student studentList) {
        return studentDAO.getAvgForStudentAtDiscipline(teacher, studentList);
    }

    public Student getStudentByUserName(String loginName) {
        return studentDAO.getStudentByUserName(loginName);
    }

    public IStudentDAO getStudentDAO() {
        return studentDAO;
    }

    public void setStudentDAO(IStudentDAO studentDAO) {
        this.studentDAO = studentDAO;
    }

}
